<template>
<!-- 订单管理 -->
    <div>
        <el-card class="box-card">
          
          <div class="div-1">
            <div class="div-2" @click="select(3)" :class="{'click_color':click_color_index==3}">
                全部订单
            </div>
            <div class="div-2" @click="select(0)" :class="{'click_color':click_color_index==0}">
                待支付
            </div>
            <div class="div-2" @click="select(2)" :class="{'click_color':click_color_index==2}">
                未支付
            </div>
            <div class="div-2" @click="select(1)" :class="{'click_color':click_color_index==1}">
                已支付
            </div>
          </div>
          <div class="div-3">
            <div class="div33">
              <div class="div33-1">
                <p class="div33-1-p">订单信息</p>
              </div>
              <div class="div33-2">
                <p class="div33-1-p">价格</p>
              </div>
              <div class="div33-3">
                <p class="div33-1-p">状态</p>
              </div>
              <div class="div33-3">
                <p class="div33-1-p">操作</p>
              </div>
            </div>
            <div class="div-4">
              <div class="div-4-box"  v-for="item in tableData" :key="item.id">
                <div class="div4-1">
                  <p>{{item.createTime}}</p>
                </div>
                <div class="div4-2">
                  <div class="div4-2-1">
                    <div class="div4-2-1-1">
                      <img class="img1" :src="'http://101.43.223.224:8765/image/getImageById?id='+item.imageId"/>
                    </div>
                  </div>
                  <div class="div4-2-2">
                    <p>{{item.courseTitle}}</p>
                  </div>
                  <div class="div4-2-3">
                    <p v-if='item.payType == 0'>免费</p>
                    <p v-if='item.payType == 1'>
                      <span class="span-1">{{item.payPrice}}元</span>
                    </p>
                  </div>
                  <div class="div4-2-4">
                    <p>{{item.orderState==0?"待支付":item.orderState==1?"已支付":'未支付'}}</p>
                  </div>
                  <div class="div4-2-5">
                    <!-- 待支付 -->
                    <p @click="controls(item.id)" v-if="item.orderState == 0"><el-button type="text">支付订单</el-button></p>
                    <!-- 未支付 -->
                    <p @click="controls(item.id)" v-if="item.orderState == 2"><el-button type="text">支付订单</el-button></p>
                    <!-- 已支付 -->
                    <p @click="cancelOrder(item.id)" v-if="item.orderState == 1"><el-button type="text">取消订单</el-button></p>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </el-card>
    </div>
</template>
<script>
export default {
  name: 'OrderManagement',
  data () {
    return {
        click_color_index: -1,
        tableData: [],
        tableData1: [{
          id: 1,
          date: '2016-05-02',
          name: 'Spring零基础入门到精通',
          jiage: '199.00',
          status: '0'
        }, {
          id: 2,
          date: '2016-05-04',
          name: 'Spring零基础入门到精通',
          jiage: '199.00',
          status: '1'
        }, {
          id: 3,
          date: '2016-05-01',
          name: 'Spring零基础入门到精通',
          jiage: '199.00',
          status: '1'
        }, {
          id: 4,
          date: '2016-05-03',
          name: 'Spring零基础入门到精通，一套搞定spring全套教程（含实战源码）',
          // ，一套搞定spring全套教程（含实战源码）
          jiage: '199.00',
          status: '0'
        }]
    }
  },
  mounted () {
    this.select()
  },
  methods: {
    // 根据用户id和收藏类型查询数据
    selectOrderEntityDTO (data) {
      this.$axios.get('/order/selectOrderEntityDTO',
          {
            params: {
              userId: window.sessionStorage.getItem('userId'),
              orderState: data
            }
          } 
        ).then(res => {
            if(res.data.flag){
                this.tableData = res.data.data
                console.log(this.tableData)
                this.message('success', '获取订单信息成功')
            }else{
                this.message('error', '获取订单信息失败,请重新登录')
            }
        }).catch(err => {
            console.log(err)
        })
    },
    select (data) {
      this.click_color_index = data
      if(data === 3){
        this.selectOrderEntityDTO()
      } else{
        this.selectOrderEntityDTO(data)
      }
    },
    cancelOrder (data) {
      
    },
    controls (data){
      console.log(data)
    }
  }
}
</script>

<style scoped>
  .box-card {
    width: 900px;
    margin: 0 auto;
    border-radius: 10px;
  }
  .div-1 {
    width: 100%;
    height: 40px;
    background-color: #f5f5f5;
  }
  .div-2 {
    width: 100px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-weight: bold;
    border-radius: 10px;
    float: left;
    font-size: 16px;
    cursor: pointer;
  }
  .click_color {
    background-color: rgb(232,242,254);
    color: rgb(32,128,247);
    font-size: 16px;
  }
  .div-3 {
    width: 100%;
    height: 1000px;
    background-color: rgb(255, 255, 255);
  }
  .img1 {
    width: 100%;
    height: 100%;
    background-size:100% 100%;
    background-repeat:no-repeat;
  }
  .div-4 {
    width: 100%;
    height: 500px;
    /* background-color: red; */
  }
  .div4-1{
    width: 100%;
    height: 50px;
    background-color: rgb(245,248,250);
    border-radius: 10px;
    font-size: 16px;
  }
  .div4-1 p {
    width: 180px;
    height: 30px;
    margin-left: 16px;
    padding-top: 12px;
    font-size: 16px;
  }
  .div4-2 {
    width: 100%;
    height: 100px;
    /* background-color: rgb(36, 137, 205); */
    /* 边框变黑1px */
    border-bottom: 1px solid rgb(210,211,212);
  }
  .div4-2-1{
    width: 120px;
    height: 100px;
    float: left;
  }
  .div4-2-2 {
    width: 280px;
    height: 100px;
    float: left;
    font-size: 16px;
  }
  .div4-2-3 {
    width: 150px;
    height: 100px;
    float: left;
  }
  .div4-2-4 {
    width: 150px;
    height: 100px;
    float: left;
  }
  .div4-2-5{
    width: 150px;
    height: 100px;
    float: left;
  }
  .div4-2-5 p{
    width: 100px;
    margin-left: 10px;
    text-align: left;
    margin-top: 32px;
    font-size: 16px;
  }
  .div4-2-1-1 {
    width: 100px;
    height: 60px;
    margin: 0 auto;
    margin-top: 20px;
  }
  .div4-2-2 p{
    width: 90%;
    height: 40px;
    text-align: left;
    margin: 0 auto;
    margin-top: 30px;
    overflow: hidden;
    font-size: 16px;
  }
  .div4-2-3 p{
    width: 90%;
    height: 40px;
    text-align: left;
    margin: 0 auto;
    margin-top: 40px;
    font-size: 16px;
  }
  .div4-2-4 p{
    width: 90%;
    height: 40px;
    text-align: left;
    margin: 0 auto;
    margin-top: 40px;
    font-size: 16px;
  }
  .div4-2-4-span{
    width: 90%;
    height: 40px;
    text-align: left;
    margin: 0 auto;
    margin-top: 40px;
    font-size: 16px;
  }
  .div-4-box {
    width: 100%;
    height: 150px;
    border-radius: 10px;
    margin-top: 20px;
  }
  .div33 {
    width: 100%;
    height: 24px;
    border: 1px solid rgb(245,248,250);
    /* border-bottom: 0.1px solid rgb(144,147,153); */
    font-weight: bold;
    margin-top: 10px;
  }
  .div33-1 {
    width: 400px;
    height: 100%;
    float: left;
  }
  .div33-2 {
    width: 150px;
    height: 100%;
    float: left;
  }
  .div33-3 {
    width: 150px;
    height: 100%;
    float: left;
  }
  .div33-1-p{
    width: 100%;
    height: 100%;
    font-size: 12px;
    text-align: left;
    margin-top: 4px;
    margin-left: 10px;
    color: rgb(161,169,178);
  }
</style>
